<?php

/**
 * UniversityNews filter form base class.
 *
 * @package    Amman to London
 * @subpackage filter
 * @author     Adel Abu-Saif <adeljas@msn.com>
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseUniversityNewsFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'university_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('University'), 'add_empty' => true)),
      'title_en'      => new sfWidgetFormFilterInput(),
      'text_en'       => new sfWidgetFormFilterInput(),
      'image_en'      => new sfWidgetFormFilterInput(),
      'title_ar'      => new sfWidgetFormFilterInput(),
      'text_ar'       => new sfWidgetFormFilterInput(),
      'image_ar'      => new sfWidgetFormFilterInput(),
      'expiry_date'   => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'university_id' => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('University'), 'column' => 'id')),
      'title_en'      => new sfValidatorPass(array('required' => false)),
      'text_en'       => new sfValidatorPass(array('required' => false)),
      'image_en'      => new sfValidatorPass(array('required' => false)),
      'title_ar'      => new sfValidatorPass(array('required' => false)),
      'text_ar'       => new sfValidatorPass(array('required' => false)),
      'image_ar'      => new sfValidatorPass(array('required' => false)),
      'expiry_date'   => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDateTime(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('university_news_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'UniversityNews';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'university_id' => 'ForeignKey',
      'title_en'      => 'Text',
      'text_en'       => 'Text',
      'image_en'      => 'Text',
      'title_ar'      => 'Text',
      'text_ar'       => 'Text',
      'image_ar'      => 'Text',
      'expiry_date'   => 'Date',
    );
  }
}
